package schoolsource.model;

import java.util.ArrayList;
import java.util.logging.Level;

import schoolsource.sql.SchoolDBSQL;
import schoolsource.util.SchoolLogger;


/**
*
*
*
**/
public class Communication2Container extends Container {


//  private StringItem assignedMessageID = new StringItem(SchoolDBSQL.MESSAGETABLE + "." + SchoolDBSQL.MSGASSIGNEDID, "", true);
//  private StringItem toID = new StringItem(SchoolDBSQL.CONTACTSTABLE + "." + SchoolDBSQL.CTTOID, "", true);
//  private StringItem fromID = new StringItem(SchoolDBSQL.CONTACTSTABLE + "." + SchoolDBSQL.CTFROMID, "", true);
//  private StringItem classAssignedID = new StringItem(SchoolDBSQL.CONTACTSTABLE + "." + SchoolDBSQL.CLASSASSIGNEDID, "", true);
//  private DateItem dateTimeSent = new DateItem(SchoolDBSQL.MESSAGETABLE + "." + SchoolDBSQL.MSGTIMESENT, "", true);
//  private StringItem subject = new StringItem(SchoolDBSQL.MESSAGETABLE + "." + SchoolDBSQL.MSGSUBJECT, "", true);
//  private StringItem messageBody = new StringItem(SchoolDBSQL.MESSAGETABLE + "." + SchoolDBSQL.MSGBODY, "", true);
//  private BooleanItem hidden = new BooleanItem(SchoolDBSQL.CONTACTSTABLE + "." + SchoolDBSQL.MSGHIDDEN, "false", true);
  private StringItem assignedMessageID = new StringItem(SchoolDBSQL.MSGASSIGNEDID, "", true);
  private StringItem toID = new StringItem(SchoolDBSQL.CTTOID, "", true);
  private StringItem fromID = new StringItem(SchoolDBSQL.CTFROMID, "", true);
  private StringItem classAssignedID = new StringItem(SchoolDBSQL.CLASSASSIGNEDID, "", true);
  private DateItem dateTimeSent = new DateItem(SchoolDBSQL.MSGTIMESENT, "", true);
  private StringItem subject = new StringItem(SchoolDBSQL.MSGSUBJECT, "", true);
  private StringItem messageBody = new StringItem(SchoolDBSQL.MSGBODY, "", true);
  private BooleanItem hidden = new BooleanItem(SchoolDBSQL.CTHIDDEN, "false", true);


  public Communication2Container() {

  }


  public Communication2Container(String newMsgAssignedID, String toID) {
    getAssignedMessageID().setValue(newMsgAssignedID);
    getToID().setValue(toID);
//	SchoolDBSQL.getSchoolDBSQL(SchoolDBSQL.DEVDATABASENAME).loadCommunication(this, getToID().toString(), getAssignedMessageID().toString());
  }
  
  /**
   * 
   * @return
   */
  public Item[] getValidationItems() {
    ArrayList al = new ArrayList();
    al.add(dateTimeSent);
    al.add(subject);
    al.add(messageBody);

    return (Item[]) al.toArray(new Item[al.size()]);
  }
  
  /**
   * 
   * @return
   */
  public Item[] getContactsItems() {
  	ArrayList al = new ArrayList();
  	al.add(toID);
  	al.add(fromID);
  	al.add(hidden);
  	al.add(classAssignedID);
  	
  	return (Item[]) al.toArray(new Item[al.size()]);
  }

	/**
	 * 
	 * @param newMessageID
	 */
	public void setAssignedMessageID(StringItem newMessageID) {
		assignedMessageID = newMessageID;
	}


/**
 * 
 * @param newClassID
 */
  public void setClassAssignedID(StringItem newClassID) {
	classAssignedID = newClassID;
  }


/**
 * 
 * @param newToID
 */
  public void setToID(StringItem newToID) {
    toID = newToID;
  }


/**
 * 
 * @param newFromID
 */
  public void setFromID(StringItem newFromID) {
    fromID = newFromID;
  }


/**
 * 
 * @param newDateTimeSent
 */
  public void setDateTimeSent(DateItem newDateTimeSent) {
    dateTimeSent = newDateTimeSent;
  }


/**
 * 
 * @param newSubject
 */
  public void setSubject(StringItem newSubject) {
    subject = newSubject;
  }


/**
 * 
 * @param newMessageBody
 */
  public void setMessageBody(StringItem newMessageBody) {
    messageBody = newMessageBody;
  }


/**
 * 
 * @param newHidden
 */
  public void setHidden(BooleanItem newHidden) {
    hidden = newHidden;
  }


	/**
	 * 
	 * @return
	 */
	public StringItem getAssignedMessageID() {
		return assignedMessageID;
	}


/**
 * 
 * @return
 */
  public StringItem getClassAssignedID() {
    return classAssignedID;
  }


/**
 * 
 * @return
 */
  public StringItem getToID() {
    return toID;
  }


/**
 * 
 * @return
 */
  public StringItem getFromID() {
    return fromID;
  }


/**
 * 
 * @return
 */
  public DateItem getDateTimeSent() {
    return dateTimeSent;
  }


/**
 * 
 * @return
 */
  public StringItem getSubject() {
    return subject;
  }


/**
 * 
 * @return
 */
  public StringItem getMessageBody() {
    return messageBody;
  }


/**
 * 
 * @return
 */
  public BooleanItem getHidden() {
    return hidden;
  }


/**
 * 
 */
  public void printItems() {
    SchoolLogger.logger.log(Level.INFO, "CommunicationContainer.printItems(): ************************************************");
    Item iList[] = getValidationItems();
    for (int j = 0;j < iList.length; j++) {
      if (iList[j] != null) {
        SchoolLogger.logger.log(Level.INFO, iList[j].getFieldName() + ": " + iList[j].toString());
      }
    }
  }
}
